| || (Logical OR) The logical or operator is a boolean operator, and will return a value of true if the operand to the left or right of the OR operator, or both is true. The result of the operator will evaluate to false only if both the right and left operands are false. Consider the following Truth Table. Logical OR Truth Table True OR True Equals True True OR False Equals True False OR True Equals True False OR False Equals False syntax: expressionOne || expressionTwo EXAMPLE variableOne = 10; if ((10==variableOne) || (variableOne == 5)) { document.write("The Logical OR is True."); } else { document.write("The Logical OR is False"); } document.write("The value of variableOne is " + variableOne); One variable is declared, called variableOne, and has a value assigned to it of 10. Within the if statement, you'll see the one instance of the Logical OR operator, which compares the two operands and finds them to be true, thus executing the first document.write statement. If the result of the operands were found to be false, the second document.write statement would be executed. Finally, the last document write statement is used to display the value contained within the variable, variableOne. |